HTMLify
app.js
Views: 16 | Author: huxn-webdev
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | let body = document.body; let themer = document.querySelector(".themer"); const followButtons = document.querySelectorAll(".follow-button"); themer.addEventListener("click", toggleTheme); function toggleTheme() { if (body.className === "light-theme") { body.className = "dark-theme"; themer.innerText = "Light"; } else { body.className = "light-theme"; themer.innerText = "Dark"; } } followButtons.forEach((btn) => { btn.addEventListener("click", (e) => followUnFollow(e.target)); }); function followUnFollow(button) { button.classList.toggle("followed"); if (button.innerText == "Follow") button.innerText = "Unfollow"; else button.innerText = "Follow"; } |